import axios from 'axios'

import { message } from 'ant-design-vue';

const instance  = axios.create({
	baseURL: '/api',
	timeout: 5000
});


// 添加请求拦截器
instance .interceptors.request.use(
	(config) => {

	
		return config;
	},
	(error) => {
		
		return Promise.reject(error);
	}
);

// 添加响应拦截器
instance .interceptors.response.use(
    response => {

		if (response.data.code == 1) {
			return response.data;
		}

		//请求失败的处理
		message.error(response.data.msg ? response.data.msg : "操作失败");
		

		return Promise.reject(response)
	},
	err => {  
		return Promise.reject(err);
	}
);




export default instance;